library(Seurat)
library(data.table)
library(NMF)
library(rsvd)
library(Rtsne)
library(ggplot2)
library(cowplot)
library(sva)
library(igraph)
library(cccd)
library(KernSmooth)
library(beeswarm)
library(stringr)
library(formatR)
source("tools.R")
library(DESeq2)
According to the previous analysis on sample group,remove the group hc001 and cell size 2um ### Read data ### Data QA
human.only.pro <- Load_data(data_dir = "../data/human.txt")
important.genes <- c("ITGB4", "ABCB5", "KRT19", "ACTB", "KRT12", "KRT5", "GAPDH",
"KRT3", "PAX6", "WNT7A", "KRT14", "TP63", "KRT10")
human.only.pro <- human.only.pro[, colnames(human.only.pro)[unlist(lapply(colnames(human.only.pro),
function(x) return(str_split(x, "_")[[1]][2]))) %in% c("10um", "20um", "6um")]]
human.only.pro <- human.only.pro[, colnames(human.only.pro)[!unlist(lapply(colnames(human.only.pro),
function(x) return(str_split(x, "_")[[1]][1]))) %in% "hc001"]]
# only select the cells contain 10 genes expressed at least,select the genes
# must be expressed in two cells at least
human.all.DESeq <- DESeq_SeuratObj(X = human.only.pro, DESq = FALSE, min.cells = 10,
min.genes = 2)
## [1] "Scaling data matrix"
##
|
| | 0%
|
|=================================================================| 100%
all.sample.group <- unlist(lapply(human.all.DESeq@cell.names, function(x) return(str_split(x,
"_")[[1]][1])))
all.sample.size <- unlist(lapply(human.all.DESeq@cell.names, function(x) return(str_split(x,
"_")[[1]][2])))
# reset ident
human.all.DESeq <- SetIdent(human.all.DESeq, cells.use = human.all.DESeq@cell.names,
ident.use = all.sample.size)
Group_Bar(human.all.DESeq@raw.data, group = all.sample.group)
Group_Bar(human.all.DESeq@raw.data, group = all.sample.size)
# We are interested in the gene ITGB4
GenePlot(human.all.DESeq, gene1 = "ITGB4", gene2 = important.genes[2])
# VlnPlot(human.all.DESeq,features.plot = 'ITGB4',y.lab.rot = 90) # Violinn
# plot of gene ITGB in all sample
VlnPlot(human.all.DESeq, features.plot = important.genes[important.genes %in%
rownames(human.all.DESeq@raw.data)], y.lab.rot = 90) # Violinn plot of gene ITGB in all sample
Here,do the dimensionality reduction using the PCA, tSNE method
all.pbmc <- PCA.TSNE(object = human.all.DESeq, pcs.compute = FALSE, num.pcs = 28)
# FeaturePlot(object = all.pbmc,features.plot ='ITGB4',pt.size = 4,no.legend
# = FALSE) # ITGB4 gene in part dataset
FeaturePlot(object = all.pbmc, features.plot = important.genes[important.genes %in%
rownames(human.all.DESeq@raw.data)], pt.size = 1, no.legend = FALSE, reduction.use = "pca") # ITGB4 gene in part dataset
DimPlot(all.pbmc, reduction.use = "tsne", pt.size = 4) # grour by sample
DimPlot(all.pbmc, reduction.use = "pca", pt.size = 4) # grour by sample
DimHeatmap(all.pbmc, reduction.type = "pca", check.plot = FALSE)
FeatureHeatmap(all.pbmc, features.plot = "ITGB4", pt.size = 3, plot.horiz = TRUE,
cols.use = c("lightgrey", "blue"))
The Faetureplot of ITGB4, ABCB5, KRT19, ACTB, KRT12, KRT5, GAPDH, KRT3, PAX6, WNT7A, KRT14, TP63, KRT10based on PCA shows that,they only has high expression level in few samples,and expresss lowly in most sample.It means that may be these important genes express differently across sample.The plot also tell us the gene KRT5,GAPDH,PAXX6,KRT14 have more higher expression level than the other important genes.It is consistent with the result of violin plot. About the heatmap,we only show the gene ITGB4 And the FeatureHeatmap and Heamap also comfirm this phenomeno.We try the other four variable genes,which has the similar result as gene ITGB4 But the tSNE and * PCA * plot show that, the sample can not be split apparently.The result may be is not good based on the PCA and tSNE method.
Next,we will have analysis on gene differential expression.Find maker genes across sample.We use the method: **wilcox test**
# Finds markers (differentially expressed genes) for each of the identity
# classes in a dataset
all_markers <- FindAllMarkers(all.pbmc, test.use = "bimod", print.bar = FALSE)
head(all_markers)
## p_val avg_logFC pct.1 pct.2 p_val_adj cluster
## RP11-217O12.1 2.160836e-158 2.8858644 0.994 0.971 4.434900e-154 6um
## AC009501.4 5.012946e-123 3.0201807 0.724 0.231 1.028857e-118 6um
## ACTG1P12 4.280359e-95 0.4914296 0.051 0.215 8.785009e-91 6um
## PRRG3 3.425743e-69 0.9104018 0.179 0.118 7.030996e-65 6um
## CYP24A1 2.304897e-64 2.2032348 0.667 0.118 4.730571e-60 6um
## MT-CO2 2.847717e-58 -1.7518920 0.872 0.981 5.844655e-54 6um
## gene
## RP11-217O12.1 RP11-217O12.1
## AC009501.4 AC009501.4
## ACTG1P12 ACTG1P12
## PRRG3 PRRG3
## CYP24A1 CYP24A1
## MT-CO2 MT-CO2
We check whether the important genes are still in the marker genes we found from the DESeq analysis. the genes:ITGB4, KRT19, ACTB, KRT5, GAPDH, KRT3, PAX6, KRT14 are still in the marker genes.
human.heatmap <- Heatmap_fun(genes = important.genes[important.genes %in% rownames(human.all.DESeq@raw.data)],
tpm.data = all.pbmc@scale.data, condition = unique(as.character(all.pbmc@ident)),
all.condition = as.character(all.pbmc@ident))
## There ara 3 conditions
## Whether creat data accurate 0
NMF::aheatmap(human.heatmap[[2]], Rowv = NA, Colv = NA, annCol = human.heatmap[[1]],
scale = "none")
We have find all marker genes across sample,there are 2322 significant genes(adjust p-value <0.05) in all marker genes.
all.pbmc <- KClustDimension(all.pbmc, reduction.use = "pca", k.use = 3)
clusters.pca <- all.pbmc@meta.data$kdimension.ident
DimPlot(all.pbmc, pt.size = 4, group.by = "kdimension.ident")
all.pbmc <- KClustDimension(all.pbmc, reduction.use = "tsne", k.use = 3)
clusters.tsne <- all.pbmc@meta.data$kdimension.ident
DimPlot(all.pbmc, pt.size = 4, group.by = "kdimension.ident", reduction.use = "tsne")
Differential expression.
When use the DESeq,it must require the gene count matrix satisify that: every gene contains at least one zero, cannot compute log geometric means. So have to take another method to handle data,but I do not know whether it is reasonable.Just try!!!
condition.1 <- unlist(lapply(all.pbmc@cell.names, function(x) return(str_split(x,
"_")[[1]][2])))
# xdds<-DESeq_CT(count.data = all.pbmc@raw.data,condition.1 = condition.1)
load("Human.cellsize.RData")
plotDispEsts(xdds, main = "Per-gene Dispersion")
r <- DESeq_result(xdds, condition = condition.1)
load("Human.cellsize.genes.RData")
x <- as.vector(r)
library(VennDiagram)
grid.draw(venn.diagram(x[1:3], filename = NULL, fill = c("dodgerblue", "goldenrod1",
"darkorange1")))